{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python37764bitd2lconda94fc7ab78ae34cabbef0e75f5636f253",
   "display_name": "Python 3.7.7 64-bit ('d2l': conda)"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Help on built-in function pow:\n\npow(...)\n    pow(input, exponent, out=None) -> Tensor\n    \n    Takes the power of each element in :attr:`input` with :attr:`exponent` and\n    returns a tensor with the result.\n    \n    :attr:`exponent` can be either a single ``float`` number or a `Tensor`\n    with the same number of elements as :attr:`input`.\n    \n    When :attr:`exponent` is a scalar value, the operation applied is:\n    \n    .. math::\n        \\text{out}_i = x_i ^ \\text{exponent}\n    \n    When :attr:`exponent` is a tensor, the operation applied is:\n    \n    .. math::\n        \\text{out}_i = x_i ^ {\\text{exponent}_i}\n    \n    When :attr:`exponent` is a tensor, the shapes of :attr:`input`\n    and :attr:`exponent` must be :ref:`broadcastable <broadcasting-semantics>`.\n    \n    Args:\n        input (Tensor): the input tensor.\n        exponent (float or tensor): the exponent value\n        out (Tensor, optional): the output tensor.\n    \n    Example::\n    \n        >>> a = torch.randn(4)\n        >>> a\n        tensor([ 0.4331,  1.2475,  0.6834, -0.2791])\n        >>> torch.pow(a, 2)\n        tensor([ 0.1875,  1.5561,  0.4670,  0.0779])\n        >>> exp = torch.arange(1., 5.)\n    \n        >>> a = torch.arange(1., 5.)\n        >>> a\n        tensor([ 1.,  2.,  3.,  4.])\n        >>> exp\n        tensor([ 1.,  2.,  3.,  4.])\n        >>> torch.pow(a, exp)\n        tensor([   1.,    4.,   27.,  256.])\n    \n    .. function:: pow(self, exponent, out=None) -> Tensor\n    \n    :attr:`self` is a scalar ``float`` value, and :attr:`exponent` is a tensor.\n    The returned tensor :attr:`out` is of the same shape as :attr:`exponent`\n    \n    The operation applied is:\n    \n    .. math::\n        \\text{out}_i = \\text{self} ^ {\\text{exponent}_i}\n    \n    Args:\n        self (float): the scalar base value for the power operation\n        exponent (Tensor): the exponent tensor\n        out (Tensor, optional): the output tensor.\n    \n    Example::\n    \n        >>> exp = torch.arange(1., 5.)\n        >>> base = 2\n        >>> torch.pow(base, exp)\n        tensor([  2.,   4.,   8.,  16.])\n\n"
    }
   ],
   "source": [
    "import torch\n",
    "help(torch.pow)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "tensor([ 2,  4,  8, 16])"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "exp = torch.tensor([1,2,3,4])\n",
    "base = 2\n",
    "torch.pow(base, exp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "tensor([1, 2, 3, 4])"
     },
     "metadata": {},
     "execution_count": 7
    }
   ],
   "source": [
    "exp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "tensor([ 1,  4,  9, 16])"
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "torch.pow(exp, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "tensor([ 1,  8, 27, 64])"
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "torch.pow(exp, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}